#include <bits/stdc++.h>
using namespace std;
int a[20];
int n;
bool vis[20];


int sum() {
    int ans = 0;
    for (int i = n; i >= 1; i--) {
        for (int j = i - 1; j >= 1; j--){
            if (vis[i] == vis[j]) {
                if (a[i] == a[j])
                ans += a[i];
                break;
            }
        }
    }
    return ans;
}

int dfs(int d) {
    if (d == n) {
        vis[d] = 0;
        int k = sum();
        vis[d] = 1;
        int z = sum();
        return max(k, z);
    }
    int q = -1;
    vis[d] = 0;
    q = max(q, dfs(d + 1));
    vis[d] = 1;
    q = max(q, dfs(d + 1));
    return q;
}

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int t;
    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        cout << dfs(1) << endl;
    }
    return 0;
}
